﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Commonlib;
namespace DAL
{
    public class ClothCompanyDAL
    {
        /// <summary>
        /// all=1时查询全部的公司，all=0时，只查询active状态为1的公司
        /// </summary>
        public DataTable getAllCompany(bool all)
        {
            string cmdstr = "";
            if (all)
            {
                cmdstr = "select * from ClothCompany order by sequence asc";
            }
            else
            {
                cmdstr = "select * from ClothCompany where active=1  order by sequence asc";
            }
            
            return SqlHelper.ExecuteDataSet(SqlHelper.SqlConnectionString, CommandType.Text, cmdstr, null).Tables[0];
        }

        //根据公司名称返回布料公司信息
        public DataTable getCompanyByName(string companyName)
        {
            string cmdstr = "select * from ClothCompany where shortName='"+companyName+"'";
            return SqlHelper.ExecuteDataSet(SqlHelper.SqlConnectionString, CommandType.Text, cmdstr, null).Tables[0];
        }
    }
}
